Skip to main content

Export Modifier

The export modifier allows you to automatically aggregate things you want to export into a table.

Old Code
pluto
local version = 2
local function add(a, b)
return a + b
end
return {
version = version,
add = add
}
New Code
pluto
export version = 2
export function add(a, b)
return a + b
end

The return statement is automatically generated at the end of the block, so it is not limited to the top-level function:

pluto
package.preload["test"] = function()
export version = 2
export function add(a, b)
return a + b
end
-- end of scope; 'return' is automatically generated
end
print(require"test".version)

Using Compatibility Mode?

You may need to use pluto_export instead of export. Alternatively, pluto_use export will enable the keyword independently of environment settings.